import { createRouter, createWebHashHistory } from "vue-router";

import Home from '../views/home.vue'

// 获取环境变量
const base = import.meta.env.VITE_BASE_URL || '/'

const router = createRouter({
    history: createWebHashHistory(base),
    routes: [
        {
            path: '/',
            redirect: '/home'
        },
        {
            path: '/home',
            name: 'home',
            component: Home
        },
        {
            path: '/shopping',
            name: 'shopping',
            component: () => import('../views/shopping.vue')
        },
        {
            path: '/live',
            name: 'live',
            component: () => import('../views/live.vue')
        },
        {
            path: '/my',
            name: 'my',
            component: () => import('../views/my.vue')
        },
        {
            path: '/search',
            name: 'search',
            redirect: {name: 'index'},
            children: [
                {
                    path: '/',
                    name: 'index',
                    component: () => import('../views/search/searchIndex.vue')
                },
                {
                    path: 'list',
                    name: 'list',
                    component: () => import('../views/search/searchList.vue')
                },
            ],
            component: () => import('../views/search.vue')
        },
    ]
})

export default router
